\(\int (c+d x) (a+b \cot (e+f x))^2 \, dx\) [44]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [B] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 18, antiderivative size = 137 \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=-b^2 c x-\frac {1}{2} b^2 d x^2+\frac {a^2 (c+d x)^2}{2 d}-\frac {i a b (c+d x)^2}{d}-\frac {b^2 (c+d x) \cot (e+f x)}{f}+\frac {2 a b (c+d x) \log \left (1-e^{2 i (e+f x)}\right )}{f}+\frac {b^2 d \log (\sin (e+f x))}{f^2}-\frac {i a b d \operatorname {PolyLog}\left (2,e^{2 i (e+f x)}\right )}{f^2} \]

[Out]

-b^2*c*x-1/2*b^2*d*x^2+1/2*a^2*(d*x+c)^2/d-I*a*b*(d*x+c)^2/d-b^2*(d*x+c)*cot(f*x+e)/f+2*a*b*(d*x+c)*ln(1-exp(2
*I*(f*x+e)))/f+b^2*d*ln(sin(f*x+e))/f^2-I*a*b*d*polylog(2,exp(2*I*(f*x+e)))/f^2

Rubi [A] (verified)

Time = 0.22 (sec) , antiderivative size = 137, normalized size of antiderivative = 1.00, number of steps used = 9, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.389, Rules used = {3803, 3798, 2221, 2317, 2438, 3801, 3556} \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\frac {a^2 (c+d x)^2}{2 d}+\frac {2 a b (c+d x) \log \left (1-e^{2 i (e+f x)}\right )}{f}-\frac {i a b (c+d x)^2}{d}-\frac {i a b d \operatorname {PolyLog}\left (2,e^{2 i (e+f x)}\right )}{f^2}-\frac {b^2 (c+d x) \cot (e+f x)}{f}-b^2 c x+\frac {b^2 d \log (\sin (e+f x))}{f^2}-\frac {1}{2} b^2 d x^2 \]

[In]

Int[(c + d*x)*(a + b*Cot[e + f*x])^2,x]

[Out]

-(b^2*c*x) - (b^2*d*x^2)/2 + (a^2*(c + d*x)^2)/(2*d) - (I*a*b*(c + d*x)^2)/d - (b^2*(c + d*x)*Cot[e + f*x])/f
+ (2*a*b*(c + d*x)*Log[1 - E^((2*I)*(e + f*x))])/f + (b^2*d*Log[Sin[e + f*x]])/f^2 - (I*a*b*d*PolyLog[2, E^((2
*I)*(e + f*x))])/f^2

Rule 2221

Int[(((F_)^((g_.)*((e_.) + (f_.)*(x_))))^(n_.)*((c_.) + (d_.)*(x_))^(m_.))/((a_) + (b_.)*((F_)^((g_.)*((e_.) +
 (f_.)*(x_))))^(n_.)), x_Symbol] :> Simp[((c + d*x)^m/(b*f*g*n*Log[F]))*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x]
 - Dist[d*(m/(b*f*g*n*Log[F])), Int[(c + d*x)^(m - 1)*Log[1 + b*((F^(g*(e + f*x)))^n/a)], x], x] /; FreeQ[{F,
a, b, c, d, e, f, g, n}, x] && IGtQ[m, 0]

Rule 2317

Int[Log[(a_) + (b_.)*((F_)^((e_.)*((c_.) + (d_.)*(x_))))^(n_.)], x_Symbol] :> Dist[1/(d*e*n*Log[F]), Subst[Int
[Log[a + b*x]/x, x], x, (F^(e*(c + d*x)))^n], x] /; FreeQ[{F, a, b, c, d, e, n}, x] && GtQ[a, 0]

Rule 2438

Int[Log[(c_.)*((d_) + (e_.)*(x_)^(n_.))]/(x_), x_Symbol] :> Simp[-PolyLog[2, (-c)*e*x^n]/n, x] /; FreeQ[{c, d,
 e, n}, x] && EqQ[c*d, 1]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3798

Int[((c_.) + (d_.)*(x_))^(m_.)*tan[(e_.) + Pi*(k_.) + (f_.)*(x_)], x_Symbol] :> Simp[I*((c + d*x)^(m + 1)/(d*(
m + 1))), x] - Dist[2*I, Int[(c + d*x)^m*E^(2*I*k*Pi)*(E^(2*I*(e + f*x))/(1 + E^(2*I*k*Pi)*E^(2*I*(e + f*x))))
, x], x] /; FreeQ[{c, d, e, f}, x] && IntegerQ[4*k] && IGtQ[m, 0]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rule 3803

Int[((c_.) + (d_.)*(x_))^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Int[ExpandIntegrand[
(c + d*x)^m, (a + b*Tan[e + f*x])^n, x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && IGtQ[m, 0] && IGtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \int \left (a^2 (c+d x)+2 a b (c+d x) \cot (e+f x)+b^2 (c+d x) \cot ^2(e+f x)\right ) \, dx \\ & = \frac {a^2 (c+d x)^2}{2 d}+(2 a b) \int (c+d x) \cot (e+f x) \, dx+b^2 \int (c+d x) \cot ^2(e+f x) \, dx \\ & = \frac {a^2 (c+d x)^2}{2 d}-\frac {i a b (c+d x)^2}{d}-\frac {b^2 (c+d x) \cot (e+f x)}{f}-(4 i a b) \int \frac {e^{2 i (e+f x)} (c+d x)}{1-e^{2 i (e+f x)}} \, dx-b^2 \int (c+d x) \, dx+\frac {\left (b^2 d\right ) \int \cot (e+f x) \, dx}{f} \\ & = -b^2 c x-\frac {1}{2} b^2 d x^2+\frac {a^2 (c+d x)^2}{2 d}-\frac {i a b (c+d x)^2}{d}-\frac {b^2 (c+d x) \cot (e+f x)}{f}+\frac {2 a b (c+d x) \log \left (1-e^{2 i (e+f x)}\right )}{f}+\frac {b^2 d \log (\sin (e+f x))}{f^2}-\frac {(2 a b d) \int \log \left (1-e^{2 i (e+f x)}\right ) \, dx}{f} \\ & = -b^2 c x-\frac {1}{2} b^2 d x^2+\frac {a^2 (c+d x)^2}{2 d}-\frac {i a b (c+d x)^2}{d}-\frac {b^2 (c+d x) \cot (e+f x)}{f}+\frac {2 a b (c+d x) \log \left (1-e^{2 i (e+f x)}\right )}{f}+\frac {b^2 d \log (\sin (e+f x))}{f^2}+\frac {(i a b d) \text {Subst}\left (\int \frac {\log (1-x)}{x} \, dx,x,e^{2 i (e+f x)}\right )}{f^2} \\ & = -b^2 c x-\frac {1}{2} b^2 d x^2+\frac {a^2 (c+d x)^2}{2 d}-\frac {i a b (c+d x)^2}{d}-\frac {b^2 (c+d x) \cot (e+f x)}{f}+\frac {2 a b (c+d x) \log \left (1-e^{2 i (e+f x)}\right )}{f}+\frac {b^2 d \log (\sin (e+f x))}{f^2}-\frac {i a b d \operatorname {PolyLog}\left (2,e^{2 i (e+f x)}\right )}{f^2} \\ \end{align*}

Mathematica [A] (verified)

Time = 8.52 (sec) , antiderivative size = 238, normalized size of antiderivative = 1.74 \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\frac {(a+b \cot (e+f x))^2 \sin (e+f x) \left (-2 b^2 f (c+d x) \cos (e+f x)-(a-b) (a+b) (e+f x) (-2 c f+d (e-f x)) \sin (e+f x)+2 b^2 d (\log (\cos (e+f x))+\log (\tan (e+f x))) \sin (e+f x)-4 a b d e (\log (\cos (e+f x))+\log (\tan (e+f x))) \sin (e+f x)+4 a b c f (\log (\cos (e+f x))+\log (\tan (e+f x))) \sin (e+f x)+4 a b d \left ((e+f x) \log \left (1-e^{2 i (e+f x)}\right )-\frac {1}{2} i \left ((e+f x)^2+\operatorname {PolyLog}\left (2,e^{2 i (e+f x)}\right )\right )\right ) \sin (e+f x)\right )}{2 f^2 (b \cos (e+f x)+a \sin (e+f x))^2} \]

[In]

Integrate[(c + d*x)*(a + b*Cot[e + f*x])^2,x]

[Out]

((a + b*Cot[e + f*x])^2*Sin[e + f*x]*(-2*b^2*f*(c + d*x)*Cos[e + f*x] - (a - b)*(a + b)*(e + f*x)*(-2*c*f + d*
(e - f*x))*Sin[e + f*x] + 2*b^2*d*(Log[Cos[e + f*x]] + Log[Tan[e + f*x]])*Sin[e + f*x] - 4*a*b*d*e*(Log[Cos[e
+ f*x]] + Log[Tan[e + f*x]])*Sin[e + f*x] + 4*a*b*c*f*(Log[Cos[e + f*x]] + Log[Tan[e + f*x]])*Sin[e + f*x] + 4
*a*b*d*((e + f*x)*Log[1 - E^((2*I)*(e + f*x))] - (I/2)*((e + f*x)^2 + PolyLog[2, E^((2*I)*(e + f*x))]))*Sin[e
+ f*x]))/(2*f^2*(b*Cos[e + f*x] + a*Sin[e + f*x])^2)

Maple [B] (verified)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 364 vs. \(2 (127 ) = 254\).

Time = 0.72 (sec) , antiderivative size = 365, normalized size of antiderivative = 2.66

method result size
risch \(-\frac {b^{2} d \,x^{2}}{2}-\frac {2 i b^{2} \left (d x +c \right )}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right )}+\frac {a^{2} d \,x^{2}}{2}-b^{2} c x -\frac {2 i b a d \operatorname {polylog}\left (2, {\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}+a^{2} c x -\frac {4 i b a d e x}{f}+\frac {b^{2} d \ln \left ({\mathrm e}^{i \left (f x +e \right )}+1\right )}{f^{2}}-\frac {2 b^{2} d \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}+\frac {b^{2} d \ln \left ({\mathrm e}^{i \left (f x +e \right )}-1\right )}{f^{2}}+\frac {2 b a c \ln \left ({\mathrm e}^{i \left (f x +e \right )}+1\right )}{f}-\frac {4 b a c \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f}+\frac {2 b a c \ln \left ({\mathrm e}^{i \left (f x +e \right )}-1\right )}{f}+\frac {4 b e a d \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}-\frac {2 b e a d \ln \left ({\mathrm e}^{i \left (f x +e \right )}-1\right )}{f^{2}}-i a b d \,x^{2}+2 i a b c x -\frac {2 i b a d \operatorname {polylog}\left (2, -{\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}+\frac {2 b a d \ln \left (1-{\mathrm e}^{i \left (f x +e \right )}\right ) x}{f}+\frac {2 b a d \ln \left (1-{\mathrm e}^{i \left (f x +e \right )}\right ) e}{f^{2}}-\frac {2 i b a d \,e^{2}}{f^{2}}+\frac {2 b a d \ln \left ({\mathrm e}^{i \left (f x +e \right )}+1\right ) x}{f}\) \(365\)

[In]

int((d*x+c)*(a+b*cot(f*x+e))^2,x,method=_RETURNVERBOSE)

[Out]

-1/2*b^2*d*x^2-2*I*b^2*(d*x+c)/f/(exp(2*I*(f*x+e))-1)+1/2*a^2*d*x^2-b^2*c*x-2*I/f^2*b*a*d*polylog(2,exp(I*(f*x
+e)))+a^2*c*x-4*I/f*b*a*d*e*x+1/f^2*b^2*d*ln(exp(I*(f*x+e))+1)-2/f^2*b^2*d*ln(exp(I*(f*x+e)))+1/f^2*b^2*d*ln(e
xp(I*(f*x+e))-1)+2/f*b*a*c*ln(exp(I*(f*x+e))+1)-4/f*b*a*c*ln(exp(I*(f*x+e)))+2/f*b*a*c*ln(exp(I*(f*x+e))-1)+4/
f^2*b*e*a*d*ln(exp(I*(f*x+e)))-2/f^2*b*e*a*d*ln(exp(I*(f*x+e))-1)-I*a*b*d*x^2+2*I*a*b*c*x-2*I/f^2*b*a*d*polylo
g(2,-exp(I*(f*x+e)))+2/f*b*a*d*ln(1-exp(I*(f*x+e)))*x+2/f^2*b*a*d*ln(1-exp(I*(f*x+e)))*e-2*I/f^2*b*a*d*e^2+2/f
*b*a*d*ln(exp(I*(f*x+e))+1)*x

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 378 vs. \(2 (124) = 248\).

Time = 0.28 (sec) , antiderivative size = 378, normalized size of antiderivative = 2.76 \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=-\frac {2 \, b^{2} d f x + i \, a b d {\rm Li}_2\left (\cos \left (2 \, f x + 2 \, e\right ) + i \, \sin \left (2 \, f x + 2 \, e\right )\right ) \sin \left (2 \, f x + 2 \, e\right ) - i \, a b d {\rm Li}_2\left (\cos \left (2 \, f x + 2 \, e\right ) - i \, \sin \left (2 \, f x + 2 \, e\right )\right ) \sin \left (2 \, f x + 2 \, e\right ) + 2 \, b^{2} c f + {\left (2 \, a b d e - 2 \, a b c f - b^{2} d\right )} \log \left (-\frac {1}{2} \, \cos \left (2 \, f x + 2 \, e\right ) + \frac {1}{2} i \, \sin \left (2 \, f x + 2 \, e\right ) + \frac {1}{2}\right ) \sin \left (2 \, f x + 2 \, e\right ) + {\left (2 \, a b d e - 2 \, a b c f - b^{2} d\right )} \log \left (-\frac {1}{2} \, \cos \left (2 \, f x + 2 \, e\right ) - \frac {1}{2} i \, \sin \left (2 \, f x + 2 \, e\right ) + \frac {1}{2}\right ) \sin \left (2 \, f x + 2 \, e\right ) - 2 \, {\left (a b d f x + a b d e\right )} \log \left (-\cos \left (2 \, f x + 2 \, e\right ) + i \, \sin \left (2 \, f x + 2 \, e\right ) + 1\right ) \sin \left (2 \, f x + 2 \, e\right ) - 2 \, {\left (a b d f x + a b d e\right )} \log \left (-\cos \left (2 \, f x + 2 \, e\right ) - i \, \sin \left (2 \, f x + 2 \, e\right ) + 1\right ) \sin \left (2 \, f x + 2 \, e\right ) + 2 \, {\left (b^{2} d f x + b^{2} c f\right )} \cos \left (2 \, f x + 2 \, e\right ) - {\left ({\left (a^{2} - b^{2}\right )} d f^{2} x^{2} + 2 \, {\left (a^{2} - b^{2}\right )} c f^{2} x\right )} \sin \left (2 \, f x + 2 \, e\right )}{2 \, f^{2} \sin \left (2 \, f x + 2 \, e\right )} \]

[In]

integrate((d*x+c)*(a+b*cot(f*x+e))^2,x, algorithm="fricas")

[Out]

-1/2*(2*b^2*d*f*x + I*a*b*d*dilog(cos(2*f*x + 2*e) + I*sin(2*f*x + 2*e))*sin(2*f*x + 2*e) - I*a*b*d*dilog(cos(
2*f*x + 2*e) - I*sin(2*f*x + 2*e))*sin(2*f*x + 2*e) + 2*b^2*c*f + (2*a*b*d*e - 2*a*b*c*f - b^2*d)*log(-1/2*cos
(2*f*x + 2*e) + 1/2*I*sin(2*f*x + 2*e) + 1/2)*sin(2*f*x + 2*e) + (2*a*b*d*e - 2*a*b*c*f - b^2*d)*log(-1/2*cos(
2*f*x + 2*e) - 1/2*I*sin(2*f*x + 2*e) + 1/2)*sin(2*f*x + 2*e) - 2*(a*b*d*f*x + a*b*d*e)*log(-cos(2*f*x + 2*e)
+ I*sin(2*f*x + 2*e) + 1)*sin(2*f*x + 2*e) - 2*(a*b*d*f*x + a*b*d*e)*log(-cos(2*f*x + 2*e) - I*sin(2*f*x + 2*e
) + 1)*sin(2*f*x + 2*e) + 2*(b^2*d*f*x + b^2*c*f)*cos(2*f*x + 2*e) - ((a^2 - b^2)*d*f^2*x^2 + 2*(a^2 - b^2)*c*
f^2*x)*sin(2*f*x + 2*e))/(f^2*sin(2*f*x + 2*e))

Sympy [F]

\[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\int \left (a + b \cot {\left (e + f x \right )}\right )^{2} \left (c + d x\right )\, dx \]

[In]

integrate((d*x+c)*(a+b*cot(f*x+e))**2,x)

[Out]

Integral((a + b*cot(e + f*x))**2*(c + d*x), x)

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 774 vs. \(2 (124) = 248\).

Time = 0.34 (sec) , antiderivative size = 774, normalized size of antiderivative = 5.65 \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\frac {2 \, {\left (f x + e\right )} a^{2} c + \frac {{\left (f x + e\right )}^{2} a^{2} d}{f} - \frac {2 \, {\left (f x + e\right )} a^{2} d e}{f} + 4 \, a b c \log \left (\sin \left (f x + e\right )\right ) - \frac {4 \, a b d e \log \left (\sin \left (f x + e\right )\right )}{f} + \frac {2 \, {\left ({\left (2 \, a b - i \, b^{2}\right )} {\left (f x + e\right )}^{2} d + 4 \, b^{2} d e - 4 \, b^{2} c f - 2 \, {\left (-i \, b^{2} d e + i \, b^{2} c f\right )} {\left (f x + e\right )} - 2 \, {\left (2 \, {\left (f x + e\right )} a b d + b^{2} d - {\left (2 \, {\left (f x + e\right )} a b d + b^{2} d\right )} \cos \left (2 \, f x + 2 \, e\right ) + {\left (-2 i \, {\left (f x + e\right )} a b d - i \, b^{2} d\right )} \sin \left (2 \, f x + 2 \, e\right )\right )} \arctan \left (\sin \left (f x + e\right ), \cos \left (f x + e\right ) + 1\right ) + 2 \, {\left (b^{2} d \cos \left (2 \, f x + 2 \, e\right ) + i \, b^{2} d \sin \left (2 \, f x + 2 \, e\right ) - b^{2} d\right )} \arctan \left (\sin \left (f x + e\right ), \cos \left (f x + e\right ) - 1\right ) - 4 \, {\left ({\left (f x + e\right )} a b d \cos \left (2 \, f x + 2 \, e\right ) + i \, {\left (f x + e\right )} a b d \sin \left (2 \, f x + 2 \, e\right ) - {\left (f x + e\right )} a b d\right )} \arctan \left (\sin \left (f x + e\right ), -\cos \left (f x + e\right ) + 1\right ) - {\left ({\left (2 \, a b - i \, b^{2}\right )} {\left (f x + e\right )}^{2} d + 2 \, {\left (i \, b^{2} d e - i \, b^{2} c f + 2 \, b^{2} d\right )} {\left (f x + e\right )}\right )} \cos \left (2 \, f x + 2 \, e\right ) - 4 \, {\left (a b d \cos \left (2 \, f x + 2 \, e\right ) + i \, a b d \sin \left (2 \, f x + 2 \, e\right ) - a b d\right )} {\rm Li}_2\left (-e^{\left (i \, f x + i \, e\right )}\right ) - 4 \, {\left (a b d \cos \left (2 \, f x + 2 \, e\right ) + i \, a b d \sin \left (2 \, f x + 2 \, e\right ) - a b d\right )} {\rm Li}_2\left (e^{\left (i \, f x + i \, e\right )}\right ) + {\left (2 i \, {\left (f x + e\right )} a b d + i \, b^{2} d + {\left (-2 i \, {\left (f x + e\right )} a b d - i \, b^{2} d\right )} \cos \left (2 \, f x + 2 \, e\right ) + {\left (2 \, {\left (f x + e\right )} a b d + b^{2} d\right )} \sin \left (2 \, f x + 2 \, e\right )\right )} \log \left (\cos \left (f x + e\right )^{2} + \sin \left (f x + e\right )^{2} + 2 \, \cos \left (f x + e\right ) + 1\right ) + {\left (2 i \, {\left (f x + e\right )} a b d + i \, b^{2} d + {\left (-2 i \, {\left (f x + e\right )} a b d - i \, b^{2} d\right )} \cos \left (2 \, f x + 2 \, e\right ) + {\left (2 \, {\left (f x + e\right )} a b d + b^{2} d\right )} \sin \left (2 \, f x + 2 \, e\right )\right )} \log \left (\cos \left (f x + e\right )^{2} + \sin \left (f x + e\right )^{2} - 2 \, \cos \left (f x + e\right ) + 1\right ) + {\left ({\left (-2 i \, a b - b^{2}\right )} {\left (f x + e\right )}^{2} d + 2 \, {\left (b^{2} d e - b^{2} c f - 2 i \, b^{2} d\right )} {\left (f x + e\right )}\right )} \sin \left (2 \, f x + 2 \, e\right )\right )}}{-2 i \, f \cos \left (2 \, f x + 2 \, e\right ) + 2 \, f \sin \left (2 \, f x + 2 \, e\right ) + 2 i \, f}}{2 \, f} \]

[In]

integrate((d*x+c)*(a+b*cot(f*x+e))^2,x, algorithm="maxima")

[Out]

1/2*(2*(f*x + e)*a^2*c + (f*x + e)^2*a^2*d/f - 2*(f*x + e)*a^2*d*e/f + 4*a*b*c*log(sin(f*x + e)) - 4*a*b*d*e*l
og(sin(f*x + e))/f + 2*((2*a*b - I*b^2)*(f*x + e)^2*d + 4*b^2*d*e - 4*b^2*c*f - 2*(-I*b^2*d*e + I*b^2*c*f)*(f*
x + e) - 2*(2*(f*x + e)*a*b*d + b^2*d - (2*(f*x + e)*a*b*d + b^2*d)*cos(2*f*x + 2*e) + (-2*I*(f*x + e)*a*b*d -
 I*b^2*d)*sin(2*f*x + 2*e))*arctan2(sin(f*x + e), cos(f*x + e) + 1) + 2*(b^2*d*cos(2*f*x + 2*e) + I*b^2*d*sin(
2*f*x + 2*e) - b^2*d)*arctan2(sin(f*x + e), cos(f*x + e) - 1) - 4*((f*x + e)*a*b*d*cos(2*f*x + 2*e) + I*(f*x +
 e)*a*b*d*sin(2*f*x + 2*e) - (f*x + e)*a*b*d)*arctan2(sin(f*x + e), -cos(f*x + e) + 1) - ((2*a*b - I*b^2)*(f*x
 + e)^2*d + 2*(I*b^2*d*e - I*b^2*c*f + 2*b^2*d)*(f*x + e))*cos(2*f*x + 2*e) - 4*(a*b*d*cos(2*f*x + 2*e) + I*a*
b*d*sin(2*f*x + 2*e) - a*b*d)*dilog(-e^(I*f*x + I*e)) - 4*(a*b*d*cos(2*f*x + 2*e) + I*a*b*d*sin(2*f*x + 2*e) -
 a*b*d)*dilog(e^(I*f*x + I*e)) + (2*I*(f*x + e)*a*b*d + I*b^2*d + (-2*I*(f*x + e)*a*b*d - I*b^2*d)*cos(2*f*x +
 2*e) + (2*(f*x + e)*a*b*d + b^2*d)*sin(2*f*x + 2*e))*log(cos(f*x + e)^2 + sin(f*x + e)^2 + 2*cos(f*x + e) + 1
) + (2*I*(f*x + e)*a*b*d + I*b^2*d + (-2*I*(f*x + e)*a*b*d - I*b^2*d)*cos(2*f*x + 2*e) + (2*(f*x + e)*a*b*d +
b^2*d)*sin(2*f*x + 2*e))*log(cos(f*x + e)^2 + sin(f*x + e)^2 - 2*cos(f*x + e) + 1) + ((-2*I*a*b - b^2)*(f*x +
e)^2*d + 2*(b^2*d*e - b^2*c*f - 2*I*b^2*d)*(f*x + e))*sin(2*f*x + 2*e))/(-2*I*f*cos(2*f*x + 2*e) + 2*f*sin(2*f
*x + 2*e) + 2*I*f))/f

Giac [F]

\[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\int { {\left (d x + c\right )} {\left (b \cot \left (f x + e\right ) + a\right )}^{2} \,d x } \]

[In]

integrate((d*x+c)*(a+b*cot(f*x+e))^2,x, algorithm="giac")

[Out]

integrate((d*x + c)*(b*cot(f*x + e) + a)^2, x)

Mupad [F(-1)]

Timed out. \[ \int (c+d x) (a+b \cot (e+f x))^2 \, dx=\int {\left (a+b\,\mathrm {cot}\left (e+f\,x\right )\right )}^2\,\left (c+d\,x\right ) \,d x \]

[In]

int((a + b*cot(e + f*x))^2*(c + d*x),x)

[Out]

int((a + b*cot(e + f*x))^2*(c + d*x), x)